package com.cqeec.gams.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.cqeec.gams.common.Function;
import com.cqeec.gams.entity.Account;
import com.cqeec.gams.service.FunctionalModuleService;

@Controller
@RequestMapping("/app/")
public class MainController {
	@Autowired
	private FunctionalModuleService fmService;

	@RequestMapping("/main.html")
	public ModelAndView gotoMainPage(HttpSession session) {
		ModelAndView mav=new ModelAndView("main");
		Object obj = session.getAttribute("account");
		if(obj==null) {
			mav.setViewName("redirect:/login.html");
			return mav;
		}
		//根据账户的权限
		Account account=(Account) obj;
		List<Function> functions=fmService.getAccountFunction(account.getId());
		mav.addObject("functions", functions);
		return mav;
	}

}
